<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.RenderResponse"%>
<%@ include file="/html/init.jsp" %>
<%@page import="com.liferay.portal.kernel.util.ListUtil" %>

<h2>List of Books</h2>

<%	
	PortletURL iteratorURL = renderResponse.createRenderURL();
	iteratorURL.setParameter("jspPage", "/html/list.jsp");
	
	List<LMSBook> lmsBooks = (List<LMSBook>)request.getAttribute("SEARCH_RESULT");
	if (Validator.isNull(lmsBooks)) {
		int end = LMSBookLocalServiceUtil.getLMSBooksCount();
		lmsBooks = LMSBookLocalServiceUtil.getLMSBooks(0, end);
	}
%>

<liferay-ui:search-container delta="4" emptyResultsMessage="no-books-to-display" iteratorURL="<%= iteratorURL %>">
	<liferay-ui:search-container-results  
		total="<%= lmsBooks.size() %>" 
		results="<%= ListUtil.subList(lmsBooks, searchContainer.getStart(), searchContainer.getEnd()) %>" />
	
	<liferay-ui:search-container-row className="LMSBook" modelVar="lmsBook">
		<liferay-ui:search-container-column-text property="bookTitle" name="book-title"/>
		
		<liferay-ui:search-container-column-text property="author"/>
		<liferay-ui:search-container-column-text>
			<fmt:formatDate value="<%= lmsBook.getCreateDate() %>" pattern="dd/MMM/yyyy"/>
		</liferay-ui:search-container-column-text>
		
		<liferay-ui:search-container-column-jsp path="/html/actions.jsp"/>		
		
	</liferay-ui:search-container-row>
	
	<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container>

<br/><a href="<portlet:renderURL/>">&laquo; Go Back</a>